<?
	$ver = $_GET["ver"];
	if ($ver<=0) return;
	$fname = "stats.txt";
	$f = fopen($fname,"r+");
	flock($f, LOCK_EX);
	@$t = fread($f, filesize($fname));
	$lines = split("\n", $t);
	
	$found = false;

	$out = "";
	for ($i=0;$i<count($lines);$i++) {
		$ar = split(",", $lines[$i]);
		if ($ar[0]<=0 || $ar[1]<=0) continue;
		if ($ar[0] == $ver) {
			$out.="$ar[0],".($ar[1]+1)."\n";	
			$found=true;
		} else {
			$out.="$ar[0],$ar[1]\n";
		}
	}
	if (!$found) {
		$out.="$ver,1\n";
	}
	fseek($f, 0);
	fwrite($f, $out);
	fclose($f);	
?>